3.4.18 \(\int \cos ^2(c+d x) (a+a \sec (c+d x))^2 (B \sec (c+d x)+C \sec ^2(c+d x)) \, dx\) [318]

3.4.18.1 Optimal result
3.4.18.2 Mathematica [A] (verified)
3.4.18.3 Rubi [A] (verified)
3.4.18.4 Maple [A] (verified)
3.4.18.5 Fricas [A] (verification not implemented)
3.4.18.6 Sympy [F]
3.4.18.7 Maxima [A] (verification not implemented)
3.4.18.8 Giac [B] (verification not implemented)
3.4.18.9 Mupad [B] (verification not implemented)

3.4.18.1 Optimal result

Integrand size = 40, antiderivative size = 73 \[ \int \cos ^2(c+d x) (a+a \sec (c+d x))^2 \left (B \sec (c+d x)+C \sec ^2(c+d x)\right ) \, dx=a^2 (2 B+C) x+\frac {a^2 (B+2 C) \text {arctanh}(\sin (c+d x))}{d}+\frac {a^2 (B-C) \sin (c+d x)}{d}+\frac {C \left (a^2+a^2 \sec (c+d x)\right ) \sin (c+d x)}{d} \]

output
a^2*(2*B+C)*x+a^2*(B+2*C)*arctanh(sin(d*x+c))/d+a^2*(B-C)*sin(d*x+c)/d+C*( 
a^2+a^2*sec(d*x+c))*sin(d*x+c)/d
 
3.4.18.2 Mathematica [A] (verified)

Time = 1.47 (sec) , antiderivative size = 143, normalized size of antiderivative = 1.96 \[ \int \cos ^2(c+d x) (a+a \sec (c+d x))^2 \left (B \sec (c+d x)+C \sec ^2(c+d x)\right ) \, dx=\frac {a^2 \left (2 B c+c C+2 B d x+C d x-B \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )-2 C \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )+B \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )+2 C \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )+B \sin (c+d x)+C \tan (c+d x)\right )}{d} \]

input
Integrate[Cos[c + d*x]^2*(a + a*Sec[c + d*x])^2*(B*Sec[c + d*x] + C*Sec[c 
+ d*x]^2),x]
 
output
(a^2*(2*B*c + c*C + 2*B*d*x + C*d*x - B*Log[Cos[(c + d*x)/2] - Sin[(c + d* 
x)/2]] - 2*C*Log[Cos[(c + d*x)/2] - Sin[(c + d*x)/2]] + B*Log[Cos[(c + d*x 
)/2] + Sin[(c + d*x)/2]] + 2*C*Log[Cos[(c + d*x)/2] + Sin[(c + d*x)/2]] + 
B*Sin[c + d*x] + C*Tan[c + d*x]))/d
 
3.4.18.3 Rubi [A] (verified)

Time = 0.54 (sec) , antiderivative size = 73, normalized size of antiderivative = 1.00, number of steps used = 7, number of rules used = 7, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.175, Rules used = {3042, 4560, 3042, 4506, 3042, 4484, 2009}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int \cos ^2(c+d x) (a \sec (c+d x)+a)^2 \left (B \sec (c+d x)+C \sec ^2(c+d x)\right ) \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {\left (a \csc \left (c+d x+\frac {\pi }{2}\right )+a\right )^2 \left (B \csc \left (c+d x+\frac {\pi }{2}\right )+C \csc \left (c+d x+\frac {\pi }{2}\right )^2\right )}{\csc \left (c+d x+\frac {\pi }{2}\right )^2}dx\)

\(\Big \downarrow \) 4560

\(\displaystyle \int \cos (c+d x) (a \sec (c+d x)+a)^2 (B+C \sec (c+d x))dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {\left (a \csc \left (c+d x+\frac {\pi }{2}\right )+a\right )^2 \left (B+C \csc \left (c+d x+\frac {\pi }{2}\right )\right )}{\csc \left (c+d x+\frac {\pi }{2}\right )}dx\)

\(\Big \downarrow \) 4506

\(\displaystyle \int \cos (c+d x) (\sec (c+d x) a+a) (a (B-C)+a (B+2 C) \sec (c+d x))dx+\frac {C \sin (c+d x) \left (a^2 \sec (c+d x)+a^2\right )}{d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {\left (\csc \left (c+d x+\frac {\pi }{2}\right ) a+a\right ) \left (a (B-C)+a (B+2 C) \csc \left (c+d x+\frac {\pi }{2}\right )\right )}{\csc \left (c+d x+\frac {\pi }{2}\right )}dx+\frac {C \sin (c+d x) \left (a^2 \sec (c+d x)+a^2\right )}{d}\)

\(\Big \downarrow \) 4484

\(\displaystyle -\int \left (-\left ((2 B+C) a^2\right )-(B+2 C) \sec (c+d x) a^2\right )dx+\frac {a^2 (B-C) \sin (c+d x)}{d}+\frac {C \sin (c+d x) \left (a^2 \sec (c+d x)+a^2\right )}{d}\)

\(\Big \downarrow \) 2009

\(\displaystyle \frac {a^2 (B+2 C) \text {arctanh}(\sin (c+d x))}{d}+\frac {a^2 (B-C) \sin (c+d x)}{d}+a^2 x (2 B+C)+\frac {C \sin (c+d x) \left (a^2 \sec (c+d x)+a^2\right )}{d}\)

input
Int[Cos[c + d*x]^2*(a + a*Sec[c + d*x])^2*(B*Sec[c + d*x] + C*Sec[c + d*x] 
^2),x]
 
output
a^2*(2*B + C)*x + (a^2*(B + 2*C)*ArcTanh[Sin[c + d*x]])/d + (a^2*(B - C)*S 
in[c + d*x])/d + (C*(a^2 + a^2*Sec[c + d*x])*Sin[c + d*x])/d
 

3.4.18.3.1 Defintions of rubi rules used

rule 2009
Int[u_, x_Symbol] :> Simp[IntSum[u, x], x] /; SumQ[u]
 

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 4484
Int[(csc[(e_.) + (f_.)*(x_)]*(d_.))^(n_)*(csc[(e_.) + (f_.)*(x_)]*(b_.) + ( 
a_))*(csc[(e_.) + (f_.)*(x_)]*(B_.) + (A_)), x_Symbol] :> Simp[A*a*Cot[e + 
f*x]*((d*Csc[e + f*x])^n/(f*n)), x] + Simp[1/(d*n)   Int[(d*Csc[e + f*x])^( 
n + 1)*Simp[n*(B*a + A*b) + (B*b*n + A*a*(n + 1))*Csc[e + f*x], x], x], x] 
/; FreeQ[{a, b, d, e, f, A, B}, x] && NeQ[A*b - a*B, 0] && LeQ[n, -1]
 

rule 4506
Int[(csc[(e_.) + (f_.)*(x_)]*(d_.))^(n_)*(csc[(e_.) + (f_.)*(x_)]*(b_.) + ( 
a_))^(m_)*(csc[(e_.) + (f_.)*(x_)]*(B_.) + (A_)), x_Symbol] :> Simp[(-b)*B* 
Cot[e + f*x]*(a + b*Csc[e + f*x])^(m - 1)*((d*Csc[e + f*x])^n/(f*(m + n))), 
 x] + Simp[1/(d*(m + n))   Int[(a + b*Csc[e + f*x])^(m - 1)*(d*Csc[e + f*x] 
)^n*Simp[a*A*d*(m + n) + B*(b*d*n) + (A*b*d*(m + n) + a*B*d*(2*m + n - 1))* 
Csc[e + f*x], x], x], x] /; FreeQ[{a, b, d, e, f, A, B, n}, x] && NeQ[A*b - 
 a*B, 0] && EqQ[a^2 - b^2, 0] && GtQ[m, 1/2] &&  !LtQ[n, -1]
 

rule 4560
Int[((a_.) + csc[(e_.) + (f_.)*(x_)]*(b_.))^(m_.)*((A_.) + csc[(e_.) + (f_. 
)*(x_)]*(B_.) + csc[(e_.) + (f_.)*(x_)]^2*(C_.))*((c_.) + csc[(e_.) + (f_.) 
*(x_)]*(d_.))^(n_.), x_Symbol] :> Simp[1/b^2   Int[(a + b*Csc[e + f*x])^(m 
+ 1)*(c + d*Csc[e + f*x])^n*(b*B - a*C + b*C*Csc[e + f*x]), x], x] /; FreeQ 
[{a, b, c, d, e, f, A, B, C, m, n}, x] && EqQ[A*b^2 - a*b*B + a^2*C, 0]
 
3.4.18.4 Maple [A] (verified)

Time = 0.27 (sec) , antiderivative size = 88, normalized size of antiderivative = 1.21

method result size
derivativedivides \(\frac {B \,a^{2} \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+C \,a^{2} \tan \left (d x +c \right )+2 B \,a^{2} \left (d x +c \right )+2 C \,a^{2} \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+B \,a^{2} \sin \left (d x +c \right )+C \,a^{2} \left (d x +c \right )}{d}\) \(88\)
default \(\frac {B \,a^{2} \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+C \,a^{2} \tan \left (d x +c \right )+2 B \,a^{2} \left (d x +c \right )+2 C \,a^{2} \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+B \,a^{2} \sin \left (d x +c \right )+C \,a^{2} \left (d x +c \right )}{d}\) \(88\)
parallelrisch \(-\frac {\left (\cos \left (d x +c \right ) \left (B +2 C \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )-\cos \left (d x +c \right ) \left (B +2 C \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )-\frac {B \sin \left (2 d x +2 c \right )}{2}-2 \left (B +\frac {C}{2}\right ) x d \cos \left (d x +c \right )-C \sin \left (d x +c \right )\right ) a^{2}}{d \cos \left (d x +c \right )}\) \(103\)
risch \(2 a^{2} B x +a^{2} x C -\frac {i B \,a^{2} {\mathrm e}^{i \left (d x +c \right )}}{2 d}+\frac {i B \,a^{2} {\mathrm e}^{-i \left (d x +c \right )}}{2 d}+\frac {2 i C \,a^{2}}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}+\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) B}{d}+\frac {2 a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) C}{d}-\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) B}{d}-\frac {2 a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) C}{d}\) \(163\)
norman \(\frac {\left (-2 B \,a^{2}-C \,a^{2}\right ) x +\left (-4 B \,a^{2}-2 C \,a^{2}\right ) x \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{6}+\left (-2 B \,a^{2}-C \,a^{2}\right ) x \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{8}+\left (2 B \,a^{2}+C \,a^{2}\right ) x \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}+\left (2 B \,a^{2}+C \,a^{2}\right ) x \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{10}+\left (4 B \,a^{2}+2 C \,a^{2}\right ) x \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{4}+\frac {4 B \,a^{2} \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3}}{d}-\frac {4 B \,a^{2} \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{7}}{d}+\frac {4 C \,a^{2} \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{5}}{d}+\frac {2 a^{2} \left (B -C \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{9}}{d}-\frac {2 a^{2} \left (B +C \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{d}}{\left (1+\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}\right )^{2} \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}-1\right )^{3}}+\frac {a^{2} \left (B +2 C \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{d}-\frac {a^{2} \left (B +2 C \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{d}\) \(330\)

input
int(cos(d*x+c)^2*(a+a*sec(d*x+c))^2*(B*sec(d*x+c)+C*sec(d*x+c)^2),x,method 
=_RETURNVERBOSE)
 
output
1/d*(B*a^2*ln(sec(d*x+c)+tan(d*x+c))+C*a^2*tan(d*x+c)+2*B*a^2*(d*x+c)+2*C* 
a^2*ln(sec(d*x+c)+tan(d*x+c))+B*a^2*sin(d*x+c)+C*a^2*(d*x+c))
 
3.4.18.5 Fricas [A] (verification not implemented)

Time = 0.27 (sec) , antiderivative size = 108, normalized size of antiderivative = 1.48 \[ \int \cos ^2(c+d x) (a+a \sec (c+d x))^2 \left (B \sec (c+d x)+C \sec ^2(c+d x)\right ) \, dx=\frac {2 \, {\left (2 \, B + C\right )} a^{2} d x \cos \left (d x + c\right ) + {\left (B + 2 \, C\right )} a^{2} \cos \left (d x + c\right ) \log \left (\sin \left (d x + c\right ) + 1\right ) - {\left (B + 2 \, C\right )} a^{2} \cos \left (d x + c\right ) \log \left (-\sin \left (d x + c\right ) + 1\right ) + 2 \, {\left (B a^{2} \cos \left (d x + c\right ) + C a^{2}\right )} \sin \left (d x + c\right )}{2 \, d \cos \left (d x + c\right )} \]

input
integrate(cos(d*x+c)^2*(a+a*sec(d*x+c))^2*(B*sec(d*x+c)+C*sec(d*x+c)^2),x, 
 algorithm="fricas")
 
output
1/2*(2*(2*B + C)*a^2*d*x*cos(d*x + c) + (B + 2*C)*a^2*cos(d*x + c)*log(sin 
(d*x + c) + 1) - (B + 2*C)*a^2*cos(d*x + c)*log(-sin(d*x + c) + 1) + 2*(B* 
a^2*cos(d*x + c) + C*a^2)*sin(d*x + c))/(d*cos(d*x + c))
 
3.4.18.6 Sympy [F]

\[ \int \cos ^2(c+d x) (a+a \sec (c+d x))^2 \left (B \sec (c+d x)+C \sec ^2(c+d x)\right ) \, dx=a^{2} \left (\int B \cos ^{2}{\left (c + d x \right )} \sec {\left (c + d x \right )}\, dx + \int 2 B \cos ^{2}{\left (c + d x \right )} \sec ^{2}{\left (c + d x \right )}\, dx + \int B \cos ^{2}{\left (c + d x \right )} \sec ^{3}{\left (c + d x \right )}\, dx + \int C \cos ^{2}{\left (c + d x \right )} \sec ^{2}{\left (c + d x \right )}\, dx + \int 2 C \cos ^{2}{\left (c + d x \right )} \sec ^{3}{\left (c + d x \right )}\, dx + \int C \cos ^{2}{\left (c + d x \right )} \sec ^{4}{\left (c + d x \right )}\, dx\right ) \]

input
integrate(cos(d*x+c)**2*(a+a*sec(d*x+c))**2*(B*sec(d*x+c)+C*sec(d*x+c)**2) 
,x)
 
output
a**2*(Integral(B*cos(c + d*x)**2*sec(c + d*x), x) + Integral(2*B*cos(c + d 
*x)**2*sec(c + d*x)**2, x) + Integral(B*cos(c + d*x)**2*sec(c + d*x)**3, x 
) + Integral(C*cos(c + d*x)**2*sec(c + d*x)**2, x) + Integral(2*C*cos(c + 
d*x)**2*sec(c + d*x)**3, x) + Integral(C*cos(c + d*x)**2*sec(c + d*x)**4, 
x))
 
3.4.18.7 Maxima [A] (verification not implemented)

Time = 0.23 (sec) , antiderivative size = 105, normalized size of antiderivative = 1.44 \[ \int \cos ^2(c+d x) (a+a \sec (c+d x))^2 \left (B \sec (c+d x)+C \sec ^2(c+d x)\right ) \, dx=\frac {4 \, {\left (d x + c\right )} B a^{2} + 2 \, {\left (d x + c\right )} C a^{2} + B a^{2} {\left (\log \left (\sin \left (d x + c\right ) + 1\right ) - \log \left (\sin \left (d x + c\right ) - 1\right )\right )} + 2 \, C a^{2} {\left (\log \left (\sin \left (d x + c\right ) + 1\right ) - \log \left (\sin \left (d x + c\right ) - 1\right )\right )} + 2 \, B a^{2} \sin \left (d x + c\right ) + 2 \, C a^{2} \tan \left (d x + c\right )}{2 \, d} \]

input
integrate(cos(d*x+c)^2*(a+a*sec(d*x+c))^2*(B*sec(d*x+c)+C*sec(d*x+c)^2),x, 
 algorithm="maxima")
 
output
1/2*(4*(d*x + c)*B*a^2 + 2*(d*x + c)*C*a^2 + B*a^2*(log(sin(d*x + c) + 1) 
- log(sin(d*x + c) - 1)) + 2*C*a^2*(log(sin(d*x + c) + 1) - log(sin(d*x + 
c) - 1)) + 2*B*a^2*sin(d*x + c) + 2*C*a^2*tan(d*x + c))/d
 
3.4.18.8 Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 157 vs. \(2 (73) = 146\).

Time = 0.31 (sec) , antiderivative size = 157, normalized size of antiderivative = 2.15 \[ \int \cos ^2(c+d x) (a+a \sec (c+d x))^2 \left (B \sec (c+d x)+C \sec ^2(c+d x)\right ) \, dx=\frac {{\left (2 \, B a^{2} + C a^{2}\right )} {\left (d x + c\right )} + {\left (B a^{2} + 2 \, C a^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right ) - {\left (B a^{2} + 2 \, C a^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right ) + \frac {2 \, {\left (B a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - C a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - B a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - C a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right )}}{\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{4} - 1}}{d} \]

input
integrate(cos(d*x+c)^2*(a+a*sec(d*x+c))^2*(B*sec(d*x+c)+C*sec(d*x+c)^2),x, 
 algorithm="giac")
 
output
((2*B*a^2 + C*a^2)*(d*x + c) + (B*a^2 + 2*C*a^2)*log(abs(tan(1/2*d*x + 1/2 
*c) + 1)) - (B*a^2 + 2*C*a^2)*log(abs(tan(1/2*d*x + 1/2*c) - 1)) + 2*(B*a^ 
2*tan(1/2*d*x + 1/2*c)^3 - C*a^2*tan(1/2*d*x + 1/2*c)^3 - B*a^2*tan(1/2*d* 
x + 1/2*c) - C*a^2*tan(1/2*d*x + 1/2*c))/(tan(1/2*d*x + 1/2*c)^4 - 1))/d
 
3.4.18.9 Mupad [B] (verification not implemented)

Time = 15.37 (sec) , antiderivative size = 161, normalized size of antiderivative = 2.21 \[ \int \cos ^2(c+d x) (a+a \sec (c+d x))^2 \left (B \sec (c+d x)+C \sec ^2(c+d x)\right ) \, dx=\frac {B\,a^2\,\sin \left (c+d\,x\right )}{d}+\frac {4\,B\,a^2\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{d}+\frac {2\,B\,a^2\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{d}+\frac {2\,C\,a^2\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{d}+\frac {4\,C\,a^2\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{d}+\frac {C\,a^2\,\sin \left (c+d\,x\right )}{d\,\cos \left (c+d\,x\right )} \]

input
int(cos(c + d*x)^2*(B/cos(c + d*x) + C/cos(c + d*x)^2)*(a + a/cos(c + d*x) 
)^2,x)
 
output
(B*a^2*sin(c + d*x))/d + (4*B*a^2*atan(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/ 
2)))/d + (2*B*a^2*atanh(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2)))/d + (2*C*a 
^2*atan(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2)))/d + (4*C*a^2*atanh(sin(c/2 
 + (d*x)/2)/cos(c/2 + (d*x)/2)))/d + (C*a^2*sin(c + d*x))/(d*cos(c + d*x))